[IA64] Strengthen dom0_getmemlist
authorawilliam@xenbuild.aw <awilliam@xenbuild.aw>
Mon, 15 May 2006 19:42:18 +0000 (13:42 -0600)
committerawilliam@xenbuild.aw <awilliam@xenbuild.aw>
Mon, 15 May 2006 19:42:18 +0000 (13:42 -0600)
reset num_pfns before hypercalling, more checks in hypercall, cleanup

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
tools/libxc/xc_ia64_stubs.c
xen/arch/ia64/xen/dom0_ops.c

index 97da325f0335868b16625d4081504327f93610fa..58d07477cc4c78ee6c47028089af99758e82d260 100644 (file)
@@ -50,7 +50,7 @@ xc_plan9_build(int xc_handle,
 }
 /*  
     VMM uses put_user to copy pfn_list to guest buffer, this maybe fail,
-    VMM don't handle this now.
+    VMM doesn't handle this now.
     This method will touch guest buffer to make sure the buffer's mapping
     is tracked by VMM,
  */
@@ -66,6 +66,7 @@ int xc_ia64_get_pfn_list(int xc_handle,
     unsigned int __start_page, __nr_pages;
     unsigned long max_pfns;
     unsigned long *__pfn_buf;
+
     __start_page = start_page;
     __nr_pages = nr_pages;
     __pfn_buf = pfn_buf;
@@ -75,6 +76,7 @@ int xc_ia64_get_pfn_list(int xc_handle,
         op.cmd = DOM0_GETMEMLIST;
         op.u.getmemlist.domain   = (domid_t)domid;
         op.u.getmemlist.max_pfns = max_pfns;
+        op.u.getmemlist.num_pfns = 0;
         set_xen_guest_handle(op.u.getmemlist.buffer, __pfn_buf);
 
         if ( (max_pfns != -1UL)
index 7066ab8e02270410d4b935dd41b13da9b638de87..cdad3ad9410edbcdea99c363364802bbd33e158f 100644 (file)
@@ -151,10 +151,7 @@ long arch_do_dom0_op(dom0_op_t *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
         put_domain(d);
     }
     break;
-    /*
-     * NOTE: DOM0_GETMEMLIST has somewhat different semantics on IA64 -
-     * it actually allocates and maps pages.
-     */
+
     case DOM0_GETMEMLIST:
     {
         unsigned long i = 0;
@@ -198,7 +195,8 @@ long arch_do_dom0_op(dom0_op_t *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
                 ret = -ENOMEM;
 
             op->u.getmemlist.num_pfns = i - start_page;
-            copy_to_guest(u_dom0_op, op, 1);
+            if (copy_to_guest(u_dom0_op, op, 1))
+                ret = -EFAULT;
             
             put_domain(d);
         }